home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / twit / mactwit_mod.py < prev    next >
Encoding:
Python Source  |  1996-09-26  |  2.4 KB  |  98 lines  |  [TEXT/Pyth]

  1. # A stab at a python debugger
  2. import Res
  3. import Qd
  4. import Dlg
  5. import Win
  6. import FrameWork
  7. import EasyDialogs
  8. import sys
  9. import TwitCore
  10. from mac_widgets import MT_AnyList, MT_IconTextWidget
  11.  
  12. # Our dialogs
  13. ID_MODULES=512
  14. I_MODULES_TITLE=1
  15. I_MODULES=2
  16. I_VARS_TITLE=3
  17. I_VARS=4
  18. I_SOURCE_TITLE=5
  19. I_SOURCE=6
  20. I_RULER=7
  21. I_EDIT=8
  22.  
  23. class ModuleBrowser(FrameWork.DialogWindow, TwitCore.ModuleBrowser):
  24.     """The module-browser dialog - mac-dependent part"""
  25.     def open(self, module):
  26.         FrameWork.DialogWindow.open(self, ID_MODULES)
  27.         self.SetPort()
  28.         Qd.TextFont(3)
  29.         Qd.TextSize(9)
  30.         self.mi_open(module)
  31.         
  32.     def create_items(self):
  33.         """Create the lists we need"""
  34.         tp, h, rect = self.wid.GetDialogItem(I_MODULES)
  35.         self.modules = MT_AnyList(self.wid, rect, 1)
  36.         tp, h, rect = self.wid.GetDialogItem(I_VARS)
  37.         self.vars = MT_AnyList(self.wid, rect, 2)
  38.         tp, h, rect = self.wid.GetDialogItem(I_SOURCE)
  39.         self.source = MT_IconTextWidget(self.wid, rect)
  40.         
  41.     def setsource(self, msg):
  42.         tp, h, rect = self.wid.GetDialogItem(I_SOURCE_TITLE)
  43.         if self.cur_source:
  44.             Dlg.SetDialogItemText(h, self.cur_source)
  45.         else:
  46.             Dlg.SetDialogItemText(h, msg)
  47.         self.source.setcontent(self.cur_source)
  48.         
  49.     def do_itemhit(self, item, event):
  50.         (what, message, when, where, modifiers) = event
  51.         Qd.SetPort(self.wid)
  52.         where = Qd.GlobalToLocal(where)
  53.         
  54.         if item == I_MODULES:
  55.             new_module, double = self.modules.click(where, 0)
  56.             self.click_module(new_module)
  57.         elif item == I_VARS:
  58.             new_var, double = self.vars.click(where, 0)
  59.             if double:
  60.                 self.click_var(new_var)
  61.         elif item == I_SOURCE:
  62.             lineno, inborder = self.source.click(where, 0)
  63.             if lineno <> None and lineno >= 0:
  64.                 self.click_source(lineno, inborder)
  65.         elif item == I_EDIT:
  66.             self.click_edit()
  67.     
  68.     def do_rawupdate(self, window, event):
  69.         Qd.SetPort(self.wid)
  70.         rgn = self.wid.GetWindowPort().visRgn
  71.         tp, h, rect = self.wid.GetDialogItem(I_RULER)
  72.         Qd.MoveTo(rect[0], rect[1])
  73.         Qd.LineTo(rect[2], rect[1])
  74.         self.modules.update(rgn)
  75.         self.vars.update(rgn)
  76.         self.source.update(rgn)
  77.         
  78.     def force_redraw(self):
  79.         Qd.SetPort(self.wid)
  80.         Win.InvalRgn(self.wid.GetWindowPort().visRgn)
  81.         
  82.     def do_activate(self, activate, event):
  83.         self.modules.activate(activate)
  84.         self.vars.activate(activate)
  85.         self.source.activate(activate)
  86.         
  87.     def close(self):
  88.         self.parent.module_dialog = None
  89.         self.source.close()
  90.         del self.modules
  91.         del self.vars
  92.         del self.source
  93.         self.do_postclose()
  94.  
  95. if __name__ == '__main__':
  96.     main()
  97.     
  98.